sortlistmodel: Track item positions
authorBenjamin Otte <otte@redhat.com>
Fri, 17 Jul 2020 00:28:42 +0000 (02:28 +0200)
committerBenjamin Otte <otte@redhat.com>
Wed, 22 Jul 2020 12:04:40 +0000 (14:04 +0200)
commit081afc0477d646218e098bbc05907e03e9e1538d
treefb01d6ad40da7e5b612163d0b5ca375cb52b5241
parente807fc3be0785fb4d4efdb92a0901344c77d2503
sortlistmodel: Track item positions

The model now tracks the original positions on top of just the items so that
it can remove items in an items-changed emission.

It now takes twice as much memory but removes items much faster.

Benchmarks:

Removing 50% of a model:
                   before    after
   250,000 items    135ms     10ms
   500,000 items    300ms     25ms

Removing 1 item:
     4,000 items    2.2ms      0ms
     8,000 items    4.6ms      0ms
   500,000 items      ---   0.01ms
gtk/gtksortlistmodel.c